package com.drinks.yiniang.entity.message;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.hansen.library.entity.BaseJson;
import com.hansen.library.utils.StringUtils;

import java.util.List;

/**
 * 消息列表json
 *
 * @author han
 * @date 2019/11/28
 */
public class MessageJson extends BaseJson {

    public static final int ITEM_TYPE_MSG_NOTICE = 0x01;
    public static final int ITEM_TYPE_MSG_TIPS = 0x02;

    private MessageData data;

    public MessageData getData() {
        return data;
    }

    public void setData(MessageData data) {
        this.data = data;
    }

    public static class MessageData {
        private List<MessageList> data;

        public List<MessageList> getData() {
            return data;
        }

        public void setData(List<MessageList> data) {
            this.data = data;
        }
    }

    public static class MessageList implements MultiItemEntity {
        private String id;
        private String fans_id;
        //来源人昵称
        private String from_username;
        //来源人头像
        private String from_avatar;
        private String title;
        private String content;
        //关联类型 0系统消息 1订单 2社区文章收藏 3社区文章点赞 4关注 5优惠券 6社区文章加精 7勋章
        private String relate_type;
        //关联ID
        private String relate_id;
        //是否已读
        private String is_read;
        //封面
        private String cover_url;
        //时间
        private String create_time;
        //普通消息(私信)返回的数据---start
        private String relation_fans_id;
        private String brief_content;
        //还有和上面重复参数id,fans_id,is_read, is_top
        private String last_chat_time;
        private String avatar;
        private String username;
        //普通消息(私信)返回的数据---end

        @Override
        public int getItemType() {
            return getListItemType(getRelate_type());
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getFans_id() {
            return fans_id;
        }

        public void setFans_id(String fans_id) {
            this.fans_id = fans_id;
        }

        public String getFrom_username() {
            return from_username;
        }

        public void setFrom_username(String from_username) {
            this.from_username = from_username;
        }

        public String getFrom_avatar() {
            return from_avatar;
        }

        public void setFrom_avatar(String from_avatar) {
            this.from_avatar = from_avatar;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public String getRelate_type() {
            return relate_type;
        }

        public void setRelate_type(String relate_type) {
            this.relate_type = relate_type;
        }

        public String getRelate_id() {
            return relate_id;
        }

        public void setRelate_id(String relate_id) {
            this.relate_id = relate_id;
        }

        public String getIs_read() {
            return is_read;
        }

        public void setIs_read(String is_read) {
            this.is_read = is_read;
        }

        public String getCover_url() {
            return cover_url;
        }

        public void setCover_url(String cover_url) {
            this.cover_url = cover_url;
        }

        public String getCreate_time() {
            return create_time;
        }

        public void setCreate_time(String create_time) {
            this.create_time = create_time;
        }

        /**
         * 关联类型 0系统消息 1订单 2社区文章收藏 3社区文章点赞 4关注 5优惠券 6社区文章加精 7勋章
         *
         * @param type
         */
        private int getListItemType(String type) {
            if (StringUtils.isEmpty(type)) {
                return BaseMultiItemQuickAdapter.TYPE_NOT_FOUND;
            }

            switch (type) {
                case "0"://系统消息
                case "4"://关注
                case "5"://优惠券
                case "7"://勋章
                    return ITEM_TYPE_MSG_TIPS;
                case "1"://订单
                case "2"://社区文章收藏
                case "3"://社区文章点赞
                case "6"://社区文章加精华
                    return ITEM_TYPE_MSG_NOTICE;
                default:
                    return ITEM_TYPE_MSG_TIPS;
            }
        }

        //普通消息(私信)getter  setter

        public String getRelation_fans_id() {
            return relation_fans_id;
        }

        public void setRelation_fans_id(String relation_fans_id) {
            this.relation_fans_id = relation_fans_id;
        }

        public String getBrief_content() {
            return brief_content;
        }

        public void setBrief_content(String brief_content) {
            this.brief_content = brief_content;
        }

        public String getLast_chat_time() {
            return last_chat_time;
        }

        public void setLast_chat_time(String last_chat_time) {
            this.last_chat_time = last_chat_time;
        }

        public String getAvatar() {
            return avatar;
        }

        public void setAvatar(String avatar) {
            this.avatar = avatar;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }
    }
}
